package com.example.spring.framework.aop.aspect;

import com.example.spring.framework.aop.intercept.MethodInvocation;
import com.example.spring.framework.aop.intercept.MethodInterceptor;

import java.lang.reflect.Method;

/**
 * @Classname AfterThrowingAdviceInterceptor
 * @Date 2019/4/23 0:06
 * @Author admin
 * @Description TODO
 */
public class AfterThrowingJAdviceInterceptor extends AbstractAspectJAdvice implements Advice, MethodInterceptor {

    private String throwingName;

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        try {
            return invocation.procccd();
        } catch (Throwable e) {
            invokeAdviceMethod(invocation, null, e.getCause());
            throw e;
        }
    }

    public AfterThrowingJAdviceInterceptor(Method aspectMethod, Object aspectObject) {
        super(aspectMethod, aspectObject);
    }

    public void setThrowingName(String throwingName) {
        this.throwingName = throwingName;
    }
}
